namespace DotNetNuke.Services.Cache
{
    using DotNetNuke.Services.Exceptions;
    using DotNetNuke.Services.Scheduling;
    using Microsoft.VisualBasic.CompilerServices;
    using System;

    public class PurgeCache : SchedulerClient
    {
        public PurgeCache(ScheduleHistoryItem objScheduleHistoryItem)
        {
            this.ScheduleHistoryItem = objScheduleHistoryItem;
        }

        public override void DoWork()
        {
            try
            {
                string str = CachingProvider.Instance().PurgeCache();
                this.ScheduleHistoryItem.Succeeded = true;
                this.ScheduleHistoryItem.AddLogNote(str);
            }
            catch (Exception exception1)
            {
                
                Exception exc = exception1;
                this.ScheduleHistoryItem.Succeeded = false;
                this.ScheduleHistoryItem.AddLogNote(string.Format("Purging cache task failed.", exc.ToString()));
                this.Errored(ref exc);
                DotNetNuke.Services.Exceptions.Exceptions.LogException(exc);
                
            }
        }
    }
}

